from selenium.webdriver.common.by import By

from base.page_base import PageBase


class LoginPage(PageBase):

    # 元素定位
    click_yes_01=(By.XPATH,'//android.widget.Button[@resource-id="com.netease.yanxuan:id/btn_alert_positive"]')
    click_adver_02=(By.XPATH,'//android.widget.ImageView[@resource-id="com.netease.yanxuan:id/view_bg"]')
    click_der_03=(By.XPATH,'//*[@text="个人"]')
    click_way_04=(By.XPATH,'(//android.widget.ImageView[@resource-id="com.netease.yanxuan:id/img_icon"])[2]')
    click_select_05=(By.XPATH,'//android.widget.TextView[@resource-id="com.netease.yanxuan:id/newOtherLoginTypes"]')
    click_agre_06=(By.XPATH,'//android.widget.CheckBox[@resource-id="com.netease.yanxuan:id/check_box"]')
    click_emcil_07=(By.XPATH,'(//android.widget.ImageView[@resource-id="com.netease.yanxuan:id/img_icon"])[4]')
    input_name_08=(By.XPATH,'//android.widget.AutoCompleteTextView[@resource-id="com.netease.yanxuan:id/account_edit"]')
    input_password_09=(By.XPATH,'//android.widget.EditText[@resource-id="com.netease.yanxuan:id/password_edit"]')
    click_login_10=(By.XPATH,'//android.widget.TextView[@resource-id="com.netease.yanxuan:id/btn_login_content"]')
    num=(By.XPATH,'//android.widget.TextView[@resource-id="com.netease.yanxuan:id/order_tag" and @text="全部订单"]')
    num1=(By.XPATH,'//android.widget.Toast')
    def click_button(self):
        self.base_click(self.click_yes_01)
        self.base_click(self.click_adver_02)
        self.base_click(self.click_der_03)
    def click_login(self):
        self.base_click(self.click_way_04)
        self.base_click(self.click_select_05)
        self.base_click(self.click_agre_06)
        self.base_click(self.click_emcil_07)
    def input_message(self,name):
        self.base_input_text(self.input_name_08,name)
    def input_password(self,password):
        self.base_input_text(self.input_password_09,password)
    def click_login_butt(self):
        self.base_click(self.click_login_10)
    def login_flow(self,name,password):
        """登录流程"""
        self.click_button()
        self.click_login()
        self.input_message(name)
        self.input_password(password)
        self.click_login_butt()

    def get_succeed_text(self):
         return self.base_get_text(self.num)
    def get_lose_text(self):
         return self.base_get_toast(self.num1)
